import webapp2
from webapp2_extras import routes
import os
import handlers.admin as admin
import jinja2

BASE_PATH = os.path.dirname(__file__)
TEMPLATE_PATH = os.path.join(BASE_PATH,'templates/app_main')
#print TEMPLATE_PATH
JINJA_ENVIRONMENT = jinja2.Environment(
  loader=jinja2.FileSystemLoader(TEMPLATE_PATH),
  extensions=['jinja2.ext.autoescape'],
  autoescape=True,
)


app = webapp2.WSGIApplication([
        routes.PathPrefixRoute('/admin',[
                                   webapp2.Route(r'/', admin.Index),
                                   webapp2.Route(r'/test-form-blobstore', admin.TestFormBlobstore),
                                   webapp2.Route(r'/upload-image', admin.UploadImage, name='upload-image'),
                                   webapp2.Route(r'/upload-image-blobstore', admin.UploadImageBlobstore, name='upload-image-blobstore'),
                                   webapp2.Route(r'/posts', admin.ShowPosts),
                                   webapp2.Route(r'/posts/add-post', admin.AddPost, name='add-post'),                                   
                                   webapp2.Route(r'/post/<post_id:\d+>', admin.ShowPost, name='show-post'),
                                   webapp2.Route(r'/post/<post_id:\d+>/edit', admin.EditPost, name='edit-post'),
                                   webapp2.Route(r'/post/<post_id:\d+>/delete', admin.DeletePost, name='delete-post'),
                                   webapp2.Route(r'/services', admin.ServiceCategories, name = 'categories'),
                                   webapp2.Route(r'/services/<category_url>', admin.ServiceCategoryTypes, name = 'category-types'),
                                   webapp2.Route(r'/services/<category_url>/<type_url>', admin.ShowServiceType, name = 'category-type'),
                                        ])
                               ],
                              debug=True)